<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="com.biz.conf.Global"%>
<%@ include file="/jsp/taglib.jsp"%>
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商品详情</title>
<meta name="description" content="这是一个 首页面">
<meta name="keywords" content="index">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<style>
.admin-main {
	background: #fff;
}
.table-bordered {
  border:none
}

.wddd-list-jtzl{
	padding: 10px 0 0!important;
	text-align:center;
}
.wddd-list-jtzl > ul > li{
	float:left;
	cursor:pointer;
}
.dt-grid-extra-columns p{
	display:none!important;
}

.fileInput{
	height:55px;
	width:55px;
	opacity: 0;
	filter:alpha(opacity=0);
	cursor:pointer;
}

.fileInputCt{
	height: 80px;
	width: 80px;
	background:url('../../resources/images/sqshfile1.png') no-repeat scroll 0 0;
	background-size:80px;
	position:relative;
}
.fileInputC{
	height:80px;
	width:80px;
	opacity:0;
	filter:alpha(opacity=0);
	cursor:pointer;
}
.sqshplusC{
	height: 80px;
	margin-bottom: 5px;
	width: 80px;
}
.djzjsxtc select {
	width: 100%;
	border-radius: 4px;
	border: 1px solid #999;
	padding: 5px;
}
.goshowwlxx{
	color:#1493d3;	
	cursor:pointer;
}
.goshowwlxx:hover{
	text-decoration:underline;	
}
.spinfoup{
	padding:20px 0;
	font-size:15px;	
}
.spinfotable{
	margin-top:20px;	
}
.spinfotable > table{
	width:100%;
	border-left:1px solid #f2f2f2;
	color:#676a6c;
	font-size: 13px;
	background-color: #fafafa;
}
.spinfotable > table > thead > tr > th{
	padding: 8px;
	line-height: 20px;
	vertical-align: top;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color:#676a6c;
	font-weight:600;
	border: 1px solid #e4eaec;
	border-left: 0;
}
.spinfotable > table > tbody > tr > td{
	text-align:center;
	padding:5px 0;
	border-bottom:1px solid #e4eaec;
	color:#676a6c;
	font-size: 13px;
	border-right:1px solid #e4eaec;
}
.tabledowndiv{
	width:100%;
	padding:5px 10px;
	font-size:13px;
	background-color:#fafafa;
	color:#676a6c;
	border-bottom:1px solid #f2f2f2;
}
.listshow{
	line-height:24px;
	width: 50%;
	float:left;
	color:#555;
	font-size: 13px;
	font-weight:600;
	margin-bottom:5px;
}
.listshow span{
	 color:#676a6c;
	 font-size: 13px;
	font-weight:normal;
 }
.layui-layer-title{
		font-weight:600;
}
	.changefont{
		font-weight:600;
		font-size: 13px;
		color:#676a6c;
	}
</style>

<!-- 异步上传图片 -->
	<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
	<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script></head>
  <div class="admin-content">
        <div class="menumessage">
				<div class="menucontent">
                 	<div class="row spinfoup">
						<div class="col-sm-6 listshow" style="">
							<div>订单编号：<span id="orderId"></span></div>
							<div>支付流水号：<span id="payCode"></span></div>
							<div>下单时间：<span id="createTime"></span></div>
							<div>收货人：<span id="fullName"></span></div>
							<div>收货地址：<span id="addr"></span></div>
						</div>
						<div class="col-sm-6 listshow" style="">
							<div>订单类型：<span id="orderType"></span></div>
							<div>付款方式：<span id="payWay"></span></div>
							<div>配送方式：<span id="sendWay"></span></div>
							<div>联系电话：<span id="sendPhone"></span></div>
							<div>订单来源：<span id="isGroup"></span></div>
						</div>
                    </div>
                    <div class="am-u-sm-12 am-pad-none spinfotable" style="width: 100%;">
                    	<table class="" cellspacing="0">
                        	<thead>
                            	<tr>
                                	<th width="40%">商品名称</th>
                                	<th width="10%">单价</th>
                                	<th width="10%">数量</th>
                                	<th width="10%">小计</th>
                                	<th width="10%">运费</th>
                                	<th width="10%">实付款</th>
                                	<th width="10%">订单状态</th>
                                </tr>
                            </thead>
                            <tbody id="tbodyHtml">
                            	
                            </tbody>
                        </table>
                        <div class="tabledowndiv" style="width: 100%; word-wrap: break-word;font-size: 13px;">
                            <div class="am-u-sm-12" id="buyerNote" style="font-weight: 600;font-size: 14px;margin-bottom: 5px;">买家留言：</div>
                            <div class="am-u-sm-12" style="margin-bottom: 5px;" id="goodsMoney"></div>
                            <div class="am-u-sm-12" style="margin-bottom: 5px;" id="otherMoney"></div>
                        </div>
                    </div> 
                </div>
    	</div>
  	</div>
  <!-- content end -->
<input type="hidden" name="types" id="form_id">
<input type="hidden" name="types" id="obje_id">
<input type="hidden" name="types" id="obje_orderstate">
<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1"
	 style="width:800px;margin-left:-400px;height:500px; display: none;">
	<div class="admin-content" style="overflow-y:auto;">
		<div class="am-u-sm-12 am-margin am-text-right">
			<button type="button" class="am-btn am-btn-primary am-btn-xs"
					data-am-modal-close>关闭</button>
			&nbsp;&nbsp;&nbsp;&nbsp;
		</div>

		<div class="am-cf am-padding">
			<div class="am-fl am-cf">
				<strong id="operation" class="am-text-primary am-text-lg">售后详情</strong>
			</div>
		</div>
		<form class="am-u-sm-12 am-padding-0" id="form" name="form">
			<div class="am-tabs am-margin" id="form_remove">
				<div class="am-u-sm-12 am-padding-0">

					<div class="am-u-sm-12 djzjsxtc">
						<div class="am-u-sm-2 am-padding-0 am-text-center">订单编号：</div>
						<div class="am-u-sm-10">
							<span id="select_code" style="float:left;"></span>
						</div>
					</div>
					<div class="am-u-sm-12 djzjsxtc">
						<div class="am-u-sm-2 am-padding-0 am-text-center">申请金额：</div>
						<div class="am-u-sm-10">
							<span id="select_money" style="float:left;"></span>
						</div>
					</div>
					<div class="am-u-sm-12 djzjsxtc">
						<div class="am-u-sm-2 am-padding-0 am-text-center">申请原因：</div>
						<div class="am-u-sm-10">
							<span  id="select_note" style="float:left;"></span>
						</div>
					</div>
					<div class="am-u-sm-12 djzjsxtc">
						<div class="am-u-sm-2 am-padding-0 am-text-center">凭证图片：</div>
						<div class="am-u-sm-10">
							<div id="ulpiclist"></div>

						</div>
					</div>

					<div class="am-u-sm-12 djzjsxtc">
						<div class="am-u-sm-2 am-padding-0 am-text-center">审批备注：</div>
						<div class="am-u-sm-10">
							<textarea rows="3" style="width:100%;" id="select_remarks"></textarea>
						</div>
					</div>
				</div>

			</div>

		</form>

	</div>
</div>



<%--<!-- 删除提示框 -->--%>
<%--<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">--%>
	<%--<div class="am-modal-dialog">--%>
		<%--<div class="am-modal-hd">提示</div>--%>
		<%--<div class="am-modal-bd">--%>
			<%--<span id="orderspmsg"></span>--%>
		<%--</div>--%>
		<%--<div class="am-modal-footer">--%>
			<%--<input type="hidden" id="order_state"> <span--%>
				<%--class="am-modal-btn" data-am-modal-cancel>取消</span> <span--%>
				<%--class="am-modal-btn" data-am-modal-confirm onclick="saveYesNo()">确定</span>--%>
		<%--</div>--%>
	<%--</div>--%>
<%--</div>--%>
<body>
<script>
	var id=${id};
    var detailId="${detailId}";
	var picPath='<%=Global.getConfig("OSSURL")%>/';
	var picPathType3='<%=Global.getConfig("OSSURL_mainType3")%>/';
	$(function(){
		loadOrderDetails();
	});
	function loadOrderDetails()
	{
		var url="${pageContext.request.contextPath}/order/findOrderInfoById.ac?id="+id+"&detailId="+detailId;
		$.get(url,function(data){
			var res=JSON.parse(data);
			$("#orderId").html(res.CODE);
            if(res.isGroup==3){
                $("#isGroup").html("体验店");
            }else{
                $("#isGroup").html("商城");
            }
			$("#payCode").html(res.payCode);
			$("#createTime").html(res.createTime);
            if(!(res.orderSend==undefined || res.orderSend==null)){
                $("#fullName").html(res.orderSend.recPersonName);
            }

			$("#addr").html(res.pro+res.city+res.area+res.buyAddr);
	if(res.listDetail[0].buyNotes==null||res.listDetail[0].buyNotes==undefined)
	{res.listDetail[0].buyNotes='';}
			$("#buyerNote").html('<span class="changefont">买家留言：</span>'+res.listDetail[0].buyNotes);
			var goodsMoneyHtml = '';
			
// 			if(res.listDetail[i].goodsType == '0')
//        		{
//        			if(res.listDetail[i].couponsPayTotal != undefined)
//        			{
//        				goodsMoneyHtml+='商品总额：'+res.listDetail[i].price+'券<span>(含服务费6元)</span>'+'  实收金额：'+res.listDetail[i].couponsPayTotal+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>';
//        			}else{
//        				goodsMoneyHtml+='商品总额：'+res.listDetail[i].price+'券<span>(含服务费6元)</span>'+'  实收金额：0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>';
//        			}
//        		}else{
//        			goodsMoneyHtml+='商品总额：￥'+res.goodsTotal+'  实收金额：￥'+res.payTotal;
//        		}
			
			if(res.isGroup=='0')
			{$("#orderType").html('普通订单');}
			else if(res.isGroup=='1')
			{$("#orderType").html('团购订单');}


			if(res.paymentRoute=='0')
			{$("#payWay").html('余额支付');}
			else if(res.paymentRoute=='1')
			{$("#payWay").html('银联支付');}
			else if(res.paymentRoute=='2')
			{$("#payWay").html('支付宝支付');}
			else if(res.paymentRoute=='3')
			{$("#payWay").html('微信支付');}
			else if(res.paymentRoute=='7')
			{$("#payWay").html('其他支付');}
            if(!(res.orderSend==undefined || res.orderSend==null)){
                if (res.orderSend.sendType == '0') {
                    $("#sendWay").html('物流配送');
                }
                else if (res.orderSend.sendType == '1') {
                    $("#sendWay").html('自己配送');
                }
                $("#sendPhone").html(res.orderSend.userphone);
            }
			var htmlGive='';
			if(res.giveType=="0")
			{htmlGive+='赠予要求：送自己,';}
			else
			{htmlGive+='赠予要求：送他人,'+'买家手机号：'+res.givePhone+',';}
			if(res.giveMsg!=null&&res.giveMsg!=undefined&&res.giveMsg!='')
			{htmlGive+='特殊要求：'+res.giveMsg;}
			else
			{htmlGive+='特殊要求：无';}
			$("#giveMessage").html(htmlGive);
			
			if(res.isMessage=="0")
			{$("#hkMessage").html("贺卡留言：无");}
			else
			{$("#hkMessage").html("贺卡留言："+res.message);}
			
			var htmlTime='';
			var otherMoney='';
			htmlTime+='<div>下单时间：<span>'+res.createTime+'</span></div>';
			if(res.payTime!=null&&res.payTime!=''&&res.payTime!=undefined)
			{
				htmlTime+='<div>支付时间：<span>'+res.payTime+'</span></div>';	
			}
            if(!(res.orderSend==undefined || res.orderSend==null)){
                if (res.orderSend.sendTime != null && res.orderSend.sendTime != '' && res.orderSend.sendTime != undefined) {
                    htmlTime += '<div>发货时间：<span>' + res.orderSend.sendTime + '</span></div>';
                }
                if (res.orderSend.confirmTime != null && res.orderSend.confirmTime != '' && res.orderSend.confirmTime != undefined) {
                    htmlTime += '<div>签收时间：<span>' + res.orderSend.confirmTime + '</span></div>';
                }
            }
			if(res.orderRefund!=null)
			{
				if(res.orderRefund.createTime!=null&&res.orderRefund.createTime!=''&&res.orderRefund.createTime!=undefined)
				{
					htmlTime+='<div>退款申请时间：<span>'+res.orderRefund.createTime+'</span></div>';	
				}
				
				if(res.orderRefund.applyTime!=null&&res.orderRefund.applyTime!=''&&res.orderRefund.applyTime!=undefined)
				{
					htmlTime+='<div>退款审核时间：<span>'+res.orderRefund.applyTime+'</span></div>';	
				}
				if (res.orderRefund.state==1){
					htmlTime+= '<button class="btn btn-xs btn-danger"  onclick="ToExamine(\''+res.orderRefund.orderId+'\');">待审批</button>';
				} else if(res.orderRefund.state==2)  {
					htmlTime+= "<font color='green'>申请通过</font>";
				}else if(res.orderRefund.state==3)  {
					htmlTime+= "<font color='green'>申请退回</font>";
				}
				if(res.orderRefund.state=="1")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(待审批)';}
				else if(res.orderRefund.state=="2")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(已通过)';}
				else if(res.orderRefund.state=="3")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(已拒绝)';}
			}
			else{
				otherMoney+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			}
			$("#liushui").html(htmlTime);
			$("#otherMoney").html(otherMoney);
			
			//<div>申请退款时间：<span>2016-6-23 11:22:33</span></div>
        	var htmlGoods='';
        	$(res.listDetail).each(function(i){
        		htmlGoods+='<tr>'+
        		'<td style="text-align:left;">'+
        		'<div class="am-u-sm-12 am-pad-none">'+
        		'<div class="am-u-sm-4">';
				if(res.listDetail[i].mainType == '3'){
					htmlGoods+='<img src="'+picPathType3+res.listDetail[i].path+'" width="100px" height="100px"/>';
				}else{
					htmlGoods+='<img src="'+picPath+res.listDetail[i].path+'" width="100px" height="100px"/>';
				}
				htmlGoods+='</div>';
				htmlGoods+=' <div class="am-u-sm-8">'+
        		'<div>'+res.listDetail[i].goodsName+'</div>'+
        		'<div>'+res.listDetail[i].typeName1+'</div>'+
        		'<div>'+res.listDetail[i].typeName2+'</div>'+
        		'<div>'+res.listDetail[i].typeName3+'</div>'+
        		'</div></div></td>';
        		if(res.listDetail[i].goodsType == '0')
        		{
        			if(res.listDetail[i].price != undefined)
        			{
        				htmlGoods+='<td>'+res.listDetail[i].price+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元)</span></td>';
        			}else{
        				htmlGoods+='<td>0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
        			}
        		}else{
        			htmlGoods+='<td>'+res.listDetail[i].price+'元</td>';
        		}
        		htmlGoods+='<td>'+res.listDetail[i].count+'</td>';
        		
        		if(res.listDetail[i].goodsType == '0')
        		{
        			if(res.listDetail[i].goodsTotal != undefined)
        			{
        				htmlGoods+='<td>'+res.listDetail[i].goodsTotal+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元)</span></td>';
        			}else{
        				htmlGoods+='<td>0券<span>(含服务费'+res.listDetail[i].serviceTotal+'元)</span></td>';
        			}
        		}else{
        			htmlGoods+='<td>'+res.listDetail[i].serviceTotal+'元</td>';
        		}
        		if(i==0)
        		{
        			htmlGoods+=' <td rowspan="2" >'+res.freightTotal+'</td>';
        			if(res.listDetail[i].goodsType == '0')
	        		{
						var jlbHTML='';
						if(res.listDetail[i].coinPayTotal!=undefined&&res.listDetail[i].coinPayTotal!=null&&res.listDetail[i].coinPayTotal!=''&&parseFloat(res.listDetail[i].coinPayTotal)>0)
						{jlbHTML=',其中久零贝'+res.listDetail[i].coinPayTotal+'元';}
	        			if(res.listDetail[i].goodsTotal != undefined)
	        			{
	        				htmlGoods+='<td rowspan="2" >'+res.listDetail[i].goodsTotal+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元'+jlbHTML+')</span></td>';
	        				goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>'+res.listDetail[i].goodsTotal+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元)</span>'+'  实收金额：'+res.listDetail[i].goodsTotal+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元'+jlbHTML+')</span>';
	        			}else{
	        				htmlGoods+='<td rowspan="2" >0券<span>(含服务费'+res.listDetail[i].serviceTotal+'元'+jlbHTML+')</span></td>';
	        				goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>'+0+'券<span>(含服务费'+res.listDetail[i].serviceTotal+'元)</span>'+'  实收金额：0券<span>(含服务费'+res.listDetail[i].serviceTotal+'元'+jlbHTML+')</span>';
	        			}
	        		}else{
						var jlbHTML='';
						if(res.listDetail[i].coinPayTotal!=undefined&&res.listDetail[i].coinPayTotal!=null&&res.listDetail[i].coinPayTotal!=''&&parseFloat(res.listDetail[i].coinPayTotal)>0)
						{jlbHTML=',久零贝'+res.listDetail[i].coinPayTotal+'元';}
	        			htmlGoods+='<td rowspan="2" >'+res.listDetail[i].payTotal+'元'+jlbHTML+'</td>';
	        			goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>￥'+res.listDetail[i].serviceTotal+'  <span class="changefont"> 实收金额：</span>￥'+res.payTotal+'元'+jlbHTML;
	        		}
        		}
        		if(res.listDetail[i].state=="0")
    			{htmlGoods+=' <td>待付款</td>';}
    			else if(res.listDetail[i].state=="1")
    			{htmlGoods+=' <td>待发货</td>';}
    			else if(res.listDetail[i].state=="2")
    			{htmlGoods+=' <td>已发货</td>';}
    			else if(res.listDetail[i].state=="3")
    			{htmlGoods+=' <td>待评价</td>';}
    			else if(res.listDetail[i].state=="4")
    			{htmlGoods+=' <td>已完成</td>';}
    			else if(res.listDetail[i].state=="5")
    			{htmlGoods+=' <td>退款中</td>';}
    			else if(res.listDetail[i].state=="6")
    			{htmlGoods+=' <td>已退款</td>';}
    			else if(res.listDetail[i].state=="7")
    			{htmlGoods+=' <td>待备货</td>';}
    			else if(res.listDetail[i].state=="8")
    			{htmlGoods+=' <td>未备货退款</td>';}
        		htmlGoods+='</tr>';
        	});
        	
        	$("#goodsMoney").html(goodsMoneyHtml);
        	$("#tbodyHtml").html(htmlGoods);
		});
	}



	function ToExamine(detailId){
		$(':input', '#form').val('');
		$("#doc-modal-1").modal('open');
		$("#form_id").val(detailId);//选中的orderid


		$.ajax({
			url : '${pageContext.request.contextPath}/order/orderRefundObject.action',
			type : "post",
			data : {
				orderId : detailId
			},
			dataType : "json",
			success : function(data) {
				var orderRefund=data.orderRefund;
				var piclist=data.piclist;
				$("#select_code").html(orderRefund.code);
				$("#select_money").html(orderRefund.money);
				$("#select_note").html(orderRefund.note);
				$("#obje_id").val(orderRefund.id);
				$("#obje_orderstate").val(orderRefund.orderstate);


				var htmlpic='';
				htmlpic +='<ul class="floatlili" >';
				jQuery.each(piclist, function(i, val) {
					htmlpic +='<li><img src="<%=Global.getConfig("OSSURL")%>/'
							+ val.path + '" height="80" /></li>';
				});

				htmlpic += '<br class="clear" /></ul>';
				$("#ulpiclist").html(htmlpic);

			}
		});

	}
	function order_sp(state, msg) {
		$("#orderspmsg").html(msg);
		$("#order_state").val(state);
		$("#my-confirm").modal('open');
	}	//审批通过或退回
	function saveYesNo() {
		var state = $("#order_state").val();
		var obje_id = $("#obje_id").val();
		var remarks = $("#select_remarks").val();

		var orderid = $("#form_id").val();
		var orderstate =  $("#obje_orderstate").val();



		$
				.ajax({
					url : '${pageContext.request.contextPath}/order/orderRefundSp.action',
					type : "post",
					data : {
						id : obje_id,
						state : state,
						remarks : remarks,
						orderid:orderid,
						orderstate:orderstate
					},
					dataType : "json",
					success : function(data) {
						if (data=='success') {
							window.location.reload();
						} else {
							alert("提交失败,错误原因："+data);
						}
					}
				});

	}
</script>         
</body>

</html>
